//
//  ServiceManager.swift
//  
//
//  Created by tank on 2021/10/10.
//

import Foundation
import LibBase

public class ServiceManager {
    static public let shared = ServiceManager()
    
    public var device: DeviceModel {
        return (DataRepositoryManager.shared
            .repository(id: DeviceModelRepository.id) as! DeviceModelRepository).data!
    }
    
    public let loggerService: LoggerServiceProtocol = LoggerService()
    
    public private(set) lazy var eventTracking: EventTrackingProtocol = EventTracking()
    
    public var routerService: RouterServiceProtocol?
    
    public let cacheService: CacheServiceProtocol = CacheService()
    
    public var flutterService: FlutterServiceProtocol?
    
    public var authService: AuthServiceProtocol? {
        didSet {
            cacheService.setUserCache()
        }
    }
    
    public var payService: PayServiceProtocol = PayService()
    
    public let screenshotService: ScreenshotServiceProtocol = ScreenshotService()
    
    private init() {
        DataRepositoryManager.shared.register(repositoryClass: AuthRepository.self)
        DataRepositoryManager.shared.register(repositoryClass: DeviceModelRepository.self)
    }
}
